﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BW.Rabbit.Infrasttucture.Interfaces
{
    /// <summary>
    /// 仓储接口
    /// </summary>
    /// <typeparam name="T">实体</typeparam>
    public interface IBaseRepository<T> where T:class 
    {
        /// <summary>
        /// 查询数据
        /// </summary>
        /// <returns>返回任务</returns>
        IQueryable<T> GetAll();

        /// <summary>
        /// 添加数据
        /// </summary>
        /// <param name="entity">实体</param>
        /// <returns>返回任务</returns>
        Task<int> AddAsync(T entity);
        /// <summary>
        /// 批量添加数据
        /// </summary>
        /// <param name="entity">实体</param>
        /// <returns>返回任务</returns>
        Task<int> AddRangeAsync(T entity);
        /// <summary>
        /// 更新数据
        /// </summary>
        /// <param name="entity">实体</param>
        /// <returns>返回任务</returns>
        Task<int> UpdateAsync(T entity);
        /// <summary>
        /// 批量更新数据
        /// </summary>
        /// <param name="entity">实体</param>
        /// <returns>返回任务</returns>
        Task<int> UpdateRangeAsync(T entity);
    }
}
